<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <!-- <el-breadcrumb-item><i class="el-icon-lx-cascades"></i> 订单表格</el-breadcrumb-item> -->
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-tabs v-model="activeName2" @tab-click="handleClick">
                <el-tab-pane label="所有订单" name="1">

                <div class="handle-box">
                    <!-- <el-button type="primary" icon="delete" class="handle-del mr10" @click="delAll">批量删除</el-button> -->
                    <el-select v-model="select_cate" clearable placeholder="筛选条件" class="handle-select mr10" @change="changeIn()">
                        <el-option key="1" label="日期时间" value="date"></el-option>
                        <!-- <el-option key="2" label="订单编号" value="order"></el-option> -->
                        <el-option key="2" label="手机号" value="phone"></el-option>
                        <el-option key="3" label="价格" value="price"></el-option>
                    </el-select>
                    <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10" v-if="select_cate != 'date'"></el-input>
                    <!-- <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10" ></el-input> -->
                    <el-date-picker v-model="select_word" type="date" placeholder="选择日期" v-if="select_cate == 'date'"> </el-date-picker>
                    <el-button type="primary" icon="search" @click="search">搜索</el-button>
                </div>                    
                     <el-table :data="tableData" border class="table" ref="multipleTable" @selection-change="handleSelectionChange">
                        <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
                       <!--  <el-table-column prop="transaction_id" label="支付单号" align="center" width="250">
                        </el-table-column> -->
                        <el-table-column prop="pay_time" label="支付时间" align="center" width="155">
                        </el-table-column>
                        <el-table-column prop="list_num" label="领取编号" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="order_spec" label="订单详情" align="center" min-width="360">
                             <template slot-scope="scope" >
                                <div v-for="(item,index) in scope.row.order_spec" style="text-align: left;">
                                    {{index+1}}.
                                    名称：<span><strong>{{item.good_name}}</strong></span>；
                                    <span v-if="item.spec.length > 0">
                                        <span v-for="(i,v) in item.spec">
                                            <span>{{i.spec}}，</span>
                                        </span>
                                    </span>
                                    价格：￥<span>{{item.price}}</span>元；
                                    数量：<span><strong>{{item.num}}</strong></span>个
                                </div>
                            </template>
                        </el-table-column>
                         <el-table-column prop="price" label="支付金额" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="cate" label="下单类型" align="center" width="120">
                        </el-table-column>
                        <el-table-column prop="contact" label="下单用户电话" align="center" width="120">
                             <template slot-scope="scope" >
                                <div v-if="scope.row.cate !='外卖订单'">
                                    {{scope.row.contact}}
                                </div>
                                <!-- <div v-if="scope.row.cate =='外卖订单'">
                                    {{scope.row.contact}}
                                </div> -->
                            </template>
                        </el-table-column>
                       <!--  <el-table-column prop="address" label="下单用户地址信息" align="center" width="480">
                        </el-table-column> -->

                        <el-table-column prop="pay_msg" label="是否支付" align="center">
                          <!--   <template slot-scope="scope" >
                                 <el-radio-group v-model="scope.row.is_pay">
                                      <el-radio :label="0" disabled>待支付</el-radio>
                                      <el-radio :label="1" disabled>已支付</el-radio>
                                      <el-radio :label="2" disabled>已取消</el-radio>
                                    </el-radio-group>
                            </template> -->
                        </el-table-column>

                         <el-table-column prop="is_seek" label="是否领取" align="center">
                            <template slot-scope="scope" >
                                <!--  <el-radio-group v-model="scope.row.is_pay">
                                      <el-radio :label="0" disabled>待支付</el-radio>
                                      <el-radio :label="1" disabled>已支付</el-radio>
                                      <el-radio :label="2" disabled>已取消</el-radio>
                                    </el-radio-group> -->
                                    <el-switch v-model="scope.row.is_seek" active-color="#13ce66" inactive-color="#ff4949" :disabled="scope.row.is_pay != 1|| scope.row.is_seek == true ? true:false" @change="rack(scope.$index, scope.row)">
                                    </el-switch>
                            </template>
                        </el-table-column>
                        <el-table-column fixed='right' label="操作" align="center" width="80">
                            <template slot-scope="scope">
                                <!-- <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
                                <el-button type="text" icon="el-icon-delete" class="red" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
<!--  到店订单  -->

                 <el-tab-pane label="到店" name="2">
                    <div class="handle-box">
                        <!-- <el-button type="primary" icon="delete" class="handle-del mr10" @click="delAll">批量删除</el-button> -->
                        <el-select v-model="select_cate" clearable placeholder="筛选条件" class="handle-select mr10" @change="changeIn()">
                            <el-option key="1" label="日期时间" value="date"></el-option>
                            <!-- <el-option key="2" label="订单编号" value="order"></el-option> -->
                             <el-option key="2" label="手机号(获取过手机号的用户)" value="phone"></el-option>

                            <el-option key="3" label="价格" value="price"></el-option>
                        </el-select>
                          <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10" v-if="select_cate != 'date'"></el-input>
                    <!-- <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10" ></el-input> -->
                        <el-date-picker v-model="select_word" type="date" placeholder="选择日期" v-if="select_cate == 'date'"> </el-date-picker>
                        
                        <el-button type="primary" icon="search" @click="search">搜索</el-button>
                    </div>   

                    <el-table :data="tableData" border class="table" ref="multipleTable" @selection-change="handleSelectionChange">
<!--                         <el-table-column type="selection" width="55" align="center"></el-table-column>
                        <el-table-column prop="o_id" label="单号" align="center" width="240">
                        </el-table-column> -->
                        <el-table-column prop="pay_time" label="支付时间" align="center" width="155">
                        </el-table-column>
                         <el-table-column prop="uname" label="下单微信昵称" align="center" show-overflow-tooltip>
                        </el-table-column>
                         <el-table-column prop="price" label="支付金额" align="center" >
                        </el-table-column>
<!--                         <el-table-column prop="order_no" label="商户编号" align="center" width="320">
                        </el-table-column> -->
                        <el-table-column prop="pay_msg" label="是否支付" align="center">
                           
                        </el-table-column>
                        <!--  <el-table-column prop="pay_time" label="支付时间" align="center" width="200" show-overflow-tooltip>
                        </el-table-column> -->
<!--                         <el-table-column prop="transaction_id" label="支付单号" align="center" width="560">
                        </el-table-column> -->
                        <el-table-column fixed='right' label="操作" align="center" width="80">
                            <template slot-scope="scope">
                                <!-- <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
                                <el-button type="text" icon="el-icon-delete" class="red" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                 </el-tab-pane>

<!--  外卖  -->
                <el-tab-pane label="外卖" name="3">
                     <div class="handle-box">
                        <!-- <el-button type="primary" icon="delete" class="handle-del mr10" @click="delAll">批量删除</el-button> -->
                        <!-- <el-select v-model="select_cate" clearable placeholder="筛选条件" class="handle-select mr10" @change="changeIn()">
                            <el-option key="1" label="日期时间" value="date"></el-option>
                             <el-option key="2" label="手机号(获取过手机号的用户)" value="phone"></el-option>
                            <el-option key="3" label="价格" value="price"></el-option>
                        </el-select> -->
                          <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10" v-if="select_cate != 'date'"></el-input>
                    <!-- <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10" ></el-input> -->
                        <el-date-picker v-model="select_word" type="date" placeholder="选择日期" v-if="select_cate == 'date'"> </el-date-picker>
                        
                        <el-button type="primary" icon="search" @click="search">搜索</el-button>
                    </div>   

                    <el-table :data="tableData" border class="table" ref="multipleTable" @selection-change="handleSelectionChange">
<!--                         <el-table-column type="selection" width="55" align="center"></el-table-column>
                        <el-table-column prop="o_id" label="单号" align="center" width="240">
                        </el-table-column> -->
                        <el-table-column prop="pay_time" label="下单时间" align="center" width="150">
                        </el-table-column>
                        <el-table-column prop="list_num" label="领取编号" align="center" width="70" show-overflow-tooltip>
                        </el-table-column>
                         <el-table-column prop="user.uname" label="下单微信昵称" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="order_spec" label="订单详情" align="center" min-width="360">
                             <template slot-scope="scope" >
                                <div v-for="(item,index) in scope.row.order_spec" style="text-align: left;">
                                    {{index+1}}.
                                    名称：<span><strong>{{item.good_name}}</strong></span>；
                                    <span v-if="item.spec.length > 0">
                                        <span v-for="(i,v) in item.spec">
                                            <span>{{i.spec}}，</span>
                                        </span>
                                    </span>
                                    价格：￥<span>{{item.price}}</span>元；
                                    数量：<span><strong>{{item.num}}</strong></span>个
                                </div>
                            </template>
                        </el-table-column>
<!--                         <el-table-column prop="order_no" label="商户编号" align="center" width="320">
                        </el-table-column> -->
                        <el-table-column label="配送信息" align="center">
                           <el-table-column prop="dada" label="配送员信息" width="150" >
                                <template slot-scope="scope">
                                  
                                        <span v-if="scope.row.dada.dm_name != '' || scope.row.dada.dm_name != 0">姓名:{{scope.row.dada.dm_name}}</span><br>
                                        <span v-if="scope.row.dada.dm_mobile != ''">电话:{{scope.row.dada.dm_mobile}}</span>
                                
                                    
                                </template>
                            </el-table-column>
                            <el-table-column prop="address" label="用户信息" width="320">
                                 <template slot-scope="scope">
                                    <span>姓名:{{scope.row.address.u_name ? scope.row.address.u_name : ''}} {{scope.row.address.u_sex}}</span><br>
                                    <span>电话:{{scope.row.address.u_phone}}</span><br>
                                    <span>地址:{{scope.row.address.address_name}}{{scope.row.address.plate}}</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="dada.order_status.order_status_msg" label="状态" width="70" show-overflow-tooltip>
                            </el-table-column>
                            <el-table-column label="详情查看" align="center" min-width="100">
                                <template slot-scope="scope">
                                    <el-button type="primary" plain @click="peisong(scope.$index, scope.row)">详情查看</el-button>
                                </template>
                            </el-table-column>
                        </el-table-column>
                        
                        <el-table-column prop="price" label="支付金额" align="center" min-width="100">
                        </el-table-column>
                        <!--  <el-table-column prop="pay_time" label="支付时间" align="center" width="200" show-overflow-tooltip>
                        </el-table-column> -->
<!--                         <el-table-column prop="transaction_id" label="支付单号" align="center" width="560">
                        </el-table-column> -->
                        <el-table-column fixed='right' label="操作" align="center" width="80">
                            <template slot-scope="scope">
                                <!-- <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
                                <el-button type="text" icon="el-icon-delete" class="red" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                 </el-tab-pane>

<!-- 导出execl    今日(默认)  昨日  最近一周  一个月                           -->
                  <el-tab-pane label="已付" name="4">
                     <div class="handle-box">

                        <el-select v-model="select_cate" clearable placeholder="筛选条件" class="handle-select mr10" @change="changeIn()">
                            <el-option label="日期" value="date"></el-option>
                            <el-option label="商品" value="good"></el-option>
                            <el-option label="到店" value="shop"></el-option>
                        </el-select>

                    <el-date-picker v-model="select_word" type="date" placeholder="选择日期" v-if="select_cate == 'date'"> </el-date-picker>
                        <el-button type="primary" icon="search" @click="search">搜索</el-button>
                         <el-button type="success" @click='exportExcel'>导出</el-button>
                    </div>   

                     <el-table id="out-table" :data="tableData" border class="table" ref="multipleTable" @selection-change="handleSelectionChange">
                        <el-table-column prop="o_id" label="序号" align="center">
                            <template slot-scope="scope">
                                <!-- <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
                                {{scope.$index+1}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="pay_time" label="支付时间" align="center">
                        </el-table-column>
                         <el-table-column prop="uname" label="下单微信昵称" align="center">
                        </el-table-column>
                         <el-table-column prop="price" label="支付金额" align="center">
                        </el-table-column>
                     <!--     <el-table-column prop="pay_msg" label="支付金额" align="center">
                        </el-table-column> -->
                        </el-table-column>
                        <el-table-column prop="order_as" label="来源" align="center">
                        </el-table-column>
                      
                    </el-table>
                    
                 </el-tab-pane>

            </el-tabs>
           
            <div class="pagination" v-if="activeName2 != '4'">
                <el-pagination background @current-change="handleCurrentChange" layout="prev, pager, next" :total="total" :current-page="current_page">
                </el-pagination>
            </div>
        </div>

        <!-- 编辑弹出框 -->
        <el-dialog title="编辑" :visible.sync="editVisible" width="30%">
            <el-form ref="form" :model="form" label-width="100px">
                <el-form-item label="日期">
                    <el-date-picker type="date" placeholder="选择日期" v-model="form.date" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                </el-form-item>
                <el-form-item label="姓名">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="地址">
                    <el-input v-model="form.address"></el-input>
                </el-form-item>

            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editVisible = false">取 消</el-button>
                <el-button type="primary" @click="saveEdit">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 配送信息 -->
        <el-dialog title="配送订单信息" :visible.sync="dadaVisible" min-width='300px' width="50%" v-if="activeName2 == 3">
            <!-- 
                配送员位置
                客户位置
                门店位置
             -->

             <!-- 
                订单
                客户
                配送员
              -->

              <el-form ref="form" :model="form" label-width="70px">
                <el-form-item label="订单信息" style="font-weight:600;">
                    <!-- <label style="font-size: 26px;">编号:</label>
                    <span style="font-size: 26px;margin-left: 100px;">{{form.list_num}}</span> -->
                    <el-row>
                      <el-col :span="6"><div style="font-size: 26px;">编号:</div></el-col>
                      <el-col :span="6"></el-col>
                      <el-col :span="6"><div style="font-size: 26px;">{{form.list_num}}</div></el-col>
                      <el-col :span="6"></el-col>
                    </el-row>
                    <label>详情</label>
                    <div>
                        <div v-for="(item,index) in form.order_spec">
                            <span>{{index+1}}、</span>
                            <el-row>
                              <el-col :span="12"><div>名称：{{item.good_name}}</div></el-col>
                              <el-col :span="12"><div>X {{item.num}}</div></el-col>
                            </el-row>
                            <!-- <span>名称：{{item.good_name}}</span><span style="float: right;margin-right: 200px;">X {{item.num}}</span> -->
                            <div v-if="item.spec != ''">规格： <div v-for="(i,v) in item.spec">{{i.spec}}</div> </div>
                        </div>
                    </div>
                    <hr>
                    <!-- 配送员 -->
                    <label>配送信息</label>
                    <div><!--  v-for="(item,index) in form.dada"-->
                        <div>更新时间：{{form.dada.update_time}}</div>
                        <el-row v-if="form.dada.dm_id">
                          <el-col :span="12"><div>姓名：{{form.dada.dm_name}}</div></el-col>
                          <el-col :span="12"><div>电话：{{form.dada.dm_mobile}}</div></el-col>
                        </el-row>
                        <el-row>
                          <el-col :span="12"><div style="color: red;">状态：{{form.dada.order_status.order_status_msg}}</div></el-col>
                          <el-col :span="12"><div style="color: red;" v-if="form.dada.dm_id">取消来源：{{form.dada.cancel_from}}</div></el-col>
                        </el-row>

                        <div style="color: red" v-if="form.dada.dm_id">取消原因：{{form.dada.cancel_reason}}</div>
                    </div>
                    <!-- <span v-for="item in form.dada">{{item.order_status}}</span> -->
                 
                </el-form-item>
                <el-form-item label="客户信息" style="font-weight:600;">
                    <hr>
                    <el-row>
                      <el-col :span="12"><div>姓名：{{form.address.u_name}}{{form.address.u_sex}}</div></el-col>
                      <el-col :span="12"><div>电话：{{form.address.u_phone}}</div></el-col>
                    </el-row>
                  <!--  <div><span>姓名：{{form.address.u_name}}{{form.address.u_sex}}</span><span style="float: right;margin-right: 50px;">电话：{{form.address.u_phone}}</span></div> -->
                   <div>地址：{{form.address.address_name}}{{form.address.plate}}</div>
                </el-form-item>
                
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button v-if="form.dada.order_status.order_status_id >= 5 && form.dada.is_handle != 1" plain type="primary" @click="handle">订单处理</el-button>
                <el-button plain type="primary" @click="dadaVisible = false">关 闭</el-button>
            </span>

        </el-dialog>

        <!-- 删除提示框 -->
        <el-dialog title="提示" :visible.sync="delVisible" width="300px" center>
            <div class="del-dialog-cnt">删除不可恢复，是否确定删除？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delVisible = false">取 消</el-button>
                <el-button type="primary" @click="deleteRow">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
    import bus from '../common/bus';
    import GoEasy from '../../../static/js/goeasy.js';
    import FileSaver from 'file-saver'
    import XLSX from 'xlsx'
    export default {
        inject : ['reload'],
        name: 'basetable',
        data() {
            return {
                // url: './static/vuetable.json',
                barData:[
                {
                    title:'商品',
                    name:'1',
                },
                {
                    title:'到店付',
                    name:'2',
                },
                {
                    title:'导出',
                    name:'3',
                }
                ],
                activeName2:'1',
                tableData: [],
                cur_page: 1,
                multipleSelection: [],
                select_cate: '',
                select_word: '',
                del_list: [],
                is_search: false,
                editVisible: false,
                delVisible: false,
                form: {

                    dada: {
                        is_handle:'',
                        cancel_from:'',
                        cancel_reason:'',
                        dm_id:'',
                        dm_name:'',
                        dm_mobile:'',
                        order_status:{
                            order_status_msg:'',
                        }
                    },
                    address: {
                        address_name:'',
                        u_name:'',
                        u_sex:'',
                        u_phone:'',
                        lat:'',
                        lon:''

                    }

                },
                idx: -1,
                admininfo:JSON.parse(localStorage.getItem('ms_username')),
                total:1,
                dadaVisible:false,
                date:'',
                peisongInfo:[],
                current_page:'',
            }
        },
        created() {

            this.init();
            this.getData();
            // this.reload();

            
        },
        computed: {
            data() {
                return this.tableData.filter((d) => {
                    // if(this.activeName2 == 1){

                    // }
                    let is_del = false;
                    for (let i = 0; i < this.del_list.length; i++) {
                        if (d.o_id === this.del_list[i].o_id) {
                            is_del = true;
                            break;
                        }
                    }
                    if (!is_del) {
                        if (d.o_id.indexOf(this.select_word) > -1 ) {
                            return d;
                        }
                    }
                })
            },

          // table: function () {
          //   return this.tableData.slice((this.cur_page-1)*10, 10)
          // }
        },
        methods: {
             init(){
                var that = this
                // var audio = document.getElementById('music');
                // var goeasy = new GoEasy({
                //     appkey: 'BC-4dfaa016f6c3475397155539944a7934'
                // });
                // goeasy.subscribe({
                //     channel: 'dome',
                //     onMessage: function(message){
                //         that.reload()
                //         // alert('提示：'+message.content);
                //     }
                // });

              
            },
            exportExcel () {
                 /* generate workbook object from table */
                 var date = new Date();
                 var wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
                 /* get binary string as output */
                 var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
                 try {
                     FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate()+'.xlsx')
                 } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
                 return wbout
             },
            // 分页导航
            handleCurrentChange(val) {
                
                // if(this.activeName2 == '3'){
                //     this.cur_page = val;
                //     this.$axios.get("admin/order/payall", {params:{
                //         aid: this.admininfo['admin_id'],
                //         token: this.admininfo['token'],
                //     }}).then((res) => {
                //         // console.log(res.data.data)

                //         this.total = res.data.data.length
                //         this.tableData = res.data.data.data.splice(val*10,10);
                //         console.log(this.tableData)
                        
                //     })
                // }else{
                    // console.log(val);
                    this.cur_page = val;
                    this.getData();  
                // }
            },
            // formatInfo(row,column){
            //     var str = '';
            //     for(var i=0 ; i < row.order_spec.length ; i++){
            //         // for(var j = 0; j <= row.order_spec[i].o_spec; j++){

            //             str +=  i+1+'商品:'+row.order_spec[i].good_name.good_name+',规格【加料：'+
            //             row.order_spec[i].o_spec[0].feed+'】,数量：'+row.order_spec[i].num+';'
            //         // }
            //     }
            //     // for(var i=0 ; i<= row.order_spec[0].o_spec[0].length ; i++){

            //     // }
            //     // return row.order_spec[0].o_spec[0].feed;
            //     return str;

            // },
            // 获取 easy-mock 的模拟数据
            getData() {
                // 开发环境使用 easy-mock 数据，正式环境使用 json 文件
                // if (process.env.NODE_ENV === 'development') {
                //     this.url = '/ms/table/list';
                // };
                this.tableData='';
                this.total = 1;

                if(this.activeName2 == '1'){
                     this.$axios.get("admin/order/lie", {params:{
                        aid: this.admininfo['admin_id'],
                        token: this.admininfo['token'],
                        page: this.cur_page
                    }}).then((res) => {
                        console.log(res.data.data)

                        if(res.data.status == 0){
                            this.tableData = res.data.data.data;
                            this.total = res.data.data.total 
                            this.current_page = res.data.data.current_page 
                        }else if(res.data.status == 3){
                           this.$router.push('login') 
                        }
                        
                    })
                }else if(this.activeName2 == '2'){
                     this.$axios.get("admin/order/plist", {params:{
                        aid: this.admininfo['admin_id'],
                        token: this.admininfo['token'],
                        page: this.cur_page
                    }}).then((res) => {
                        this.tableData = res.data.data.data;
                        this.total = res.data.data.total
                        this.current_page = res.data.data.current_page 
                    })

                }else if(this.activeName2 == '3'){
                    this.$axios.get("admin/order/abnormal", {params:{
                        aid: this.admininfo['admin_id'],
                        token: this.admininfo['token'],
                        page:this.page
                    }}).then((res) => {
                        console.log(res.data.data)
                        this.tableData = res.data.data.data;
                        this.total = res.data.data.total
                        this.current_page = res.data.data.current_page 
                    })

                }else if(this.activeName2 == '4'){

                    this.$axios.get("admin/order/payall", {params:{
                        aid: this.admininfo['admin_id'],
                        token: this.admininfo['token'],
                    }}).then((res) => {
                        console.log(res.data.data)
                        this.tableData = res.data.data;
                        
                    })
                }

               
            },
            search() {
                // console.log(this.select_word)
                if(this.select_cate == 'date' && this.select_word != ''){

                    var d = new Date(this.select_word);
                    this.select_word = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
                }else if(this.select_cate == 'date' && this.select_word == ''){
                   this.select_word = ''; 
                }
                if(this.activeName2 != '4' && this.select_cate != '' ){
                    this.is_search = true;
                    this.$axios.get("admin/order/search", {params:{
                        aid: this.admininfo['admin_id'],
                        token: this.admininfo['token'],
                        page: this.cur_page,
                        type: this.select_cate,
                        keyWord: this.select_word,
                        head:this.activeName2
                    }}).then((res) => {

                        if(res.data.status == 0){
                            this.tableData = res.data.data.data;
                            // console.log(this.tableData);
                            this.total = res.data.data.total;
                            this.$message.success(`有${this.total}条`);
                            // this.$refs.multipleTable.dolayout();
                        }else if(res.data.status == 5){
                            this.$message.success(`没有数据`);
                        }else{
                            this.$message.error(res.data.msg)
                        }
                        
                    })
                }else if(this.activeName2 == '4' && this.select_cate != ''){

                    this.$axios.get("admin/order/search_pay", {params:{
                        aid: this.admininfo['admin_id'],
                        token: this.admininfo['token'],
                        type: this.select_cate,
                        keyWord: this.select_word,
                    }}).then((res) => {
                        if(res.data.status == 0){
                            this.tableData = res.data.data;
                            // console.log(this.tableData);
                            // this.total = res.data.data.total;
                            this.$message.success(`有${this.tableData.length}条`);
                            // this.$refs.multipleTable.dolayout();
                        }else if(res.data.status == 5){
                            this.$message.success(`没有数据`);
                        }else{
                            this.$message.error(res.data.msg)
                        }
                        
                    })
                }else if( this.select_cate == ''){
                    this.getData()
                }
                
            },
            // search_pay(){
            //     this.$axios.get("admin/order/search", {params:{
            //             aid: this.admininfo['admin_id'],
            //             token: this.admininfo['token'],
            //             type: this.select_cate,
            //         }}).then((res) => {

            //             if(res.data.status == 0){
            //                 this.tableData = res.data.data;
            //                 console.log(this.tableData);
            //                 this.$message.success(`有${this.tableData.length}条`);
            //                 // this.$refs.multipleTable.dolayout();
            //             }else{
            //                 this.$message(res.data.msg)
            //             }
                        
            //         })
            // },
            formatter(row, column) {
                return row.address;
            },
            filterTag(value, row) {
                return row.tag === value;
            },
            handleEdit(index, row) {
                this.idx = index;
                const item = this.tableData[index];
                this.form = {
                    name: item.name,
                    date: item.date,
                    address: item.address
                }
                this.editVisible = true;
            },
            handleDelete(index, row) {
                this.idx = index;
                this.delVisible = true;
            },
            delAll() {
                const length = this.multipleSelection.length;
                let str = '';
                this.del_list = this.del_list.concat(this.multipleSelection);
                for (let i = 0; i < length; i++) {
                    str += this.multipleSelection[i].name + ' ';
                }
                this.$message.error('删除了' + str);
                this.multipleSelection = [];
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            // 保存编辑
            saveEdit() {
                this.$set(this.tableData, this.idx, this.form);
                this.editVisible = false;
                this.$message.success(`修改成功`);
            },
            // 确定删除
            deleteRow(){
                this.tableData.splice(this.idx, 1);
                this.$message.success('删除成功');
                this.delVisible = false;
            },
            handleClick(tab, event) {
                this.activeName2 = tab.name
                // if(this.activeName2 == 3){
                    this.select_cate = ''
                    this.select_word = ''
                // }
                this.getData()
          },
          changeIn(){
            // console.log(this.select_word);
            this.select_word = ''
          },
          rack(index,row){
                 this.$axios.post('admin/order/rack',{
                        aid:this.admininfo.admin_id,
                        token:this.admininfo.token,
                        oid:this.tableData[index].order_id
                    }).then((res)=>{
                        if(res.data.status == 0){
                            this.$message.success('修改成功');
                            // this.reload()
                        }else{
                             this.$message(res.data.msg);
                        }
                    })

              },
          peisong(index,row){
                this.idx = index;
                this.dadaVisible = true;
                this.form = this.tableData[index];
                // console.log(this.form)
                /*获取订单信息*/
                // this.$axios.get("admin/ddpeisong/query",{params:{order_id:this.form.o_id}})
                // .then((res) =>{
                //     // console.log(res)
                //     if(res.data.code == 0 && res.data.status == "success"){
                //         this.peisongInfo = res.data.result
                //     }else{
                //         this.$message.error(res.data.msg)
                //     }

                // })


                // console.log(index)
                // console.log(row)
                // console.log(this.form.dada);
            },
          handle(){
            // console.log(this.form.dada.dada_peisong_id)
            this.$axios.post('admin/ddpeisong/handle',{dada_peisong_id:this.form.dada.dada_peisong_id})
            .then((res) => {
                this.dadaVisible = false
                if(res.data.status == 0){
                    this.$message.success(res.data.msg)
                    this.reload();
                }else{
                    this.$message.error(res.data.msg)
                }
                
            })

          }
        }
    }

</script>

<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 120px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
    }
    .del-dialog-cnt{
        font-size: 16px;
        text-align: center
    }
    .table{
        width: 100%;
        font-size: 14px;
    }
    .red{
        color: #ff0000;
    }
    .el-tabs__item.is-top{
        font-weight: 600 !important;
        font-size: 22px;
    }
</style>
